package com.weseal.dry.config;

import common.convert.EnumConverterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.Collections;

/**
 * @title
 * @description
 * @usage
 * @copyright Copyright 2014  rrmj Corporation. All rights reserved.
 * @company 上海众多美网络科技有限公司
 * @author weseal
 * @create 2018/3/27
 */
@Configuration
@ComponentScan(basePackages = {"com.weseal"},excludeFilters = {
		@ComponentScan.Filter(type= FilterType.ANNOTATION, value = EnableWebMvc.class),
		@ComponentScan.Filter(type=FilterType.ANNOTATION , value= Controller.class)
})
@Import(DataConfig.class)
public class RootConfig {

	@Bean
	public EnumConverterFactory enumConverterFactory (){
		EnumConverterFactory enumConverterFactory = new EnumConverterFactory();
		return enumConverterFactory;
	}

	@Bean
	@DependsOn("enumConverterFactory")
	public ConversionServiceFactoryBean conversionServiceFactoryBean(){
		ConversionServiceFactoryBean  conversionServiceFactoryBean= new ConversionServiceFactoryBean();
		conversionServiceFactoryBean.setConverters(Collections.singleton(enumConverterFactory()));
		return conversionServiceFactoryBean;
	}


}
